﻿
using System;
namespace HBase {
    public class LoggerCommon {

        public static bool loggerMongon = true;
        public static bool loggerInfoLoggerFile = true;
        public static bool loggerMyConsole = false;



        static void addMongon(String s) {
            if( String.IsNullOrEmpty(s) ) {
                return;
            }
            if( !LoggerCommon.loggerMongon ) {
                return;
            }
            GuidangCache.addMessage(s);

        }
        //file all   
        public static void fileAll(string s) {
            if( String.IsNullOrEmpty(s) ) {
                return;
            }
            MyConsole.addMessage(s);
            addMongon(s);

            if( LoggerCommon.loggerInfoLoggerFile ) {
                FileLogger.Error(s ,null);
            }
            LoggerCache.has(s);
        }
        public static void error(string s ,Exception ex) {
            if( String.IsNullOrEmpty(s) ) {
                return;
            }
            MyConsole.addMessage(s);
            addMongon(s + ex.Message + ex.StackTrace);
            ;
            FileLogger.Error(s ,ex);
            LoggerCache.has(s);
        }
        public static void consol(String format ,params object[] p) {
            if( p.Length > 0 ) {
                format = String.Format(format ,p);
            }
            consol(format);
        }
        public static void consol(string s) {
            if( String.IsNullOrEmpty(s) ) {
                return;
            }
            MyConsole.addMessage(s);
            if( LoggerCache.has(s) ) {
                return;
            }
            /*
               if ( BaseConfig.loggerInfoLoggerFile ) {
                   FileLogger.Info(s);
               }*/
            addMongon(s);
        }
        public static void consoleOnly(string s) {
            if( String.IsNullOrEmpty(s) ) {
                return;
            }
            MyConsole.addMessage(s);
            if( LoggerCache.has(s) ) {
                return;
            }
        }

        public static void consoleOnly(String format ,params object[] p) {
            if( p.Length > 0 ) {
                format = String.Format(format ,p);
            }
            consoleOnly(format);
        }
    }
}
